<template>
  <div class="Image_statistics_query">
    <div class="heard_title">影像/超声质量查询</div>
    <div style="margin-top: 10px; margin-bottom: -10px">
      <el-cascader
        :options="options_a"
        collapse-tags
        v-model="OrgansArr"
        style="margin-left: 10px"
        :props="{ checkStrictly: true }"
        @change="handleChange"
        clearable
      ></el-cascader>
      <el-select
        v-model="value2"
        filterable
        style="margin-left: 20px"
        placeholder="请选择"
      >
        <el-option
          v-for="item in options"
          :key="item.Id"
          :label="item.Username"
          :value="item.Id"
        >
        </el-option>
      </el-select>
      <!-- <el-radio-group v-model="radio" style="margin-left: 10px">
        <el-radio :label="1">影像</el-radio>
        <el-radio :label="2">超声</el-radio>
      </el-radio-group>
      <el-date-picker
        v-model="formInfo.startDate"
        type="date"
        placeholder="选择日期"
        style="margin-left: 10px; width: 160px"
      >
      </el-date-picker>
      <span style="margin: 0 10px">至</span>
      <el-date-picker
        type="date"
        placeholder="选择日期"
        v-model="formInfo.endDate"
        style="width: 160px"
      >
      </el-date-picker> -->
      <el-button
        icon="el-icon-search"
        style="margin-left: 10px"
        @click="getTableData"
      ></el-button>
    </div>
    <div style="margin-top: 15px; padding: 10px">
      <el-table :data="tableData" border style="width: 100%" height="605">
        <el-table-column prop="ScoreNo" label="序列号"> </el-table-column>
        <el-table-column prop="GroupName" label="类别"> </el-table-column>
        <el-table-column prop="SumScore" label="分数"> </el-table-column>
        <el-table-column prop="CreatedUserName" label="操作人">
        </el-table-column>
        <el-table-column prop="YearMonth" label="年月"> </el-table-column>
        <!-- <el-table-column label="操作">
          <el-button size="mini">删除</el-button>
          <el-button
            size="mini"
            @click="todo"
          >重新打分</el-button>
        </el-table-column> -->
      </el-table>
      <div class="block" style="margin-top: 10px; text-align: center">
        <el-pagination
          layout="prev, pager, next"
          :total="page.total"
          :current-page.sync="page.currentpage"
          :page-size.sync="page.pagesize"
          @current-change="page_change"
        >
        </el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  // 组件名称
  name: "",
  // 局部注册的组件
  components: {},
  // 组件参数 接收来自父组件的数据
  props: {},
  // 组件状态值
  data() {
    return {
      showCheckbox: true,
      options: [],
      options_a: [],
      value2: "",
      isW: "",
      value1: "",
      orgname: 1034,
      OrgansArr: 1034,
      formInfo: {
        startDate: "",
        endDate: "",
      },
      tableData: [],
      radio: 1,
      page: {
        currentpage: 1,
        pagesize: 14,
        total: 1,
      },
      orgId: "",
    };
  },
  // 计算属性
  computed: {},
  // 侦听器
  watch: {},
  // 生命周期钩子   注：没用到的钩子请自行删除
  /**
   * 组件实例创建完成，属性已绑定，但DOM还未生成，$ el属性还不存在
   */
  created() {
    if (this.$route.query.Token != null && this.$route.query.Token != "") {
      console.log(this.$route.query.Token, "KKKKKKKKKKKKKKKKKKKKKK");
      localStorage.setItem("token", this.$route.query.Token);
    } else {
    }

    var myDate = new Date();
    var time = myDate.toLocaleDateString().split("/").join("-");
    this.formInfo.endDate = time;
    var pre = new Date();
    pre.setFullYear(pre.getFullYear() - 1);
    this.formInfo.startDate = pre.toLocaleDateString().split("/").join("-");
  },
  /**
   * el 被新创建的 vm.el 替换，并挂载到实例上去之后调用该钩子。
   * 如果 root 实例挂载了一个文档内元素，当 mounted 被调用时 vm.el 也在文档内。
   */
  mounted() {
    this.gettree_list();
    this.getuser_data();
    this.getTableData();
  },
  // 组件方法
  methods: {
    gettree_list() {
      // 获取组织数据
      this.$post(baseUrl.hrIp + "/auth/organs/searchlist", {}).then((res) => {
        if (res.code == 1) {
          this.options_a = res.data;
        }
      });
    },
    getuser_data() {
      // 获取人员数据
      this.$get(
        baseUrl.hrIp + "/hr/employees?page=1&limit=10&name=&OrgID=" + this.orgId
      ).then((res) => {
        if (res.code == 1) {
          this.options = res.data.list;
          this.userId = res.data.list[0].Id;
          this.userName = res.data.list[0].Username;
          setTimeout((_) => {
            this.isShow = true;
          }, 200);
        }
      });
    },
    handleChange(value) {
      // 组织切换事件
      this.OrgansArr = value;
      this.orgId = value[value.length - 1];
      this.getuser_data();
    },
    selectClear() {
      // 清除下拉框事件
      this.treeClick = null;
      this.selectLabel = null;
      this.selectValue = null;
    },
    filterNode(value, data) {
      if (!value) {
        return true;
      }
      return data.label.indexOf(value) !== -1;
    },
    nodeClick(obj, node) {
      // 树点击事件
      this.treeClick = obj.value;
      this.selectLabel = obj.label;
      this.selectValue = obj.value;
    },
    checkChange(obj, node) {
      // 多选框点击事件
    },
    todo() {
      // 查询跳转事件
      this.$router.push({
        path: "/Image_scoring_standard",
        query: { OrgansArr: this.OrgansArr, user: this.value2 },
      });
    },
    getTableData() {
      // 获取表单数据
      // if (this.value2 == 0) {
      //   var body = {
      //     currentpage: this.page.currentpage,
      //     pagesize: this.page.pagesize,
      //     Condition: "HospitalID=" + this.OrgansArr,
      //   };
      // }
      // if (this.value2 != 0) {
      var body = {
        currentpage: this.page.currentpage,
        pagesize: this.page.pagesize,
        HospitalID: this.orgId,
        Condition: "DoctorID=" + this.value2,
      };
      // }

      this.$post("/qc_Score/GetListByCondition", body).then((res) => {
        if (res.code == 0) {
          this.tableData = res.data;
          this.page.total = res.pageinfo.totalrecords;
        }
      });
    },
    page_change(val) {
      // 页码切换事件
      this.page.currentpage = val;
      this.getTableData();
    },
  },
};
</script>

<style scoped lang="less">
</style>
